package nl.project.dataImport;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;

public class Testje extends HttpServlet {
	
	DatastoreService dt = DatastoreServiceFactory.getDatastoreService();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		
		ArrayList<String> l  =new ArrayList<String>();
		
		l.add("bla1");
		l.add("bla2");
		l.add("bla3");
		
		Entity e = new Entity("test", 1);
		e.setProperty("list", l);
		
		dt.put(e);
		
		PrintWriter p = resp.getWriter();
		
		
		try {
			
		Entity f =	dt.get(e.getKey());
		
		ArrayList<String > g = (ArrayList<String>)f.getProperty("list");
		p.println(g.get(0));
		p.println(g.get(1));
		p.println(g.get(2));

		p.flush();
			
		} catch (EntityNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
	
		
		
	}

}
